package com.hotel.controller;

import com.hotel.entity.Consumption;
import com.hotel.service.ConsumptionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api")
public class ConsumptionController {
    @Autowired
    private ConsumptionService consumptionService;
    //保存消费记录
    @PostMapping("/admin/consumptions")
    public void save(@RequestBody Consumption consumption) {
        consumptionService.save(consumption);
    }

    //查看入住记录的消费情况
    @GetMapping({"/admin/consumptions/{checkid}","/client/consumptions/{checkid}"})
    public List<Map<String,Object>> findById(@PathVariable Integer checkid) {
        return consumptionService.findById(checkid);
    }
    //删除消费记录
    @DeleteMapping("/admin/consumptions/{id}")
    public void delete(@PathVariable Integer id) {
        consumptionService.deleteById(id);
    }
}
